import { find } from "lodash";

export const getTableColumns = ({ params, orgList }: any) => [
	{
		title: "环线编号",
		dataIndex: "id",
		width: 140,
		ellipsis: true
	},
	{
		title: "环线名称",
		dataIndex: "loopName",
		width: 140,
		ellipsis: true
	},
	{
		title: "所属组织",
		dataIndex: "createOrgId",
		width: 140,
		ellipsis: true,
		render: (_: any, record: any) => {
			const result = find(orgList?.data || [], (item: any) => item.id === record.createOrgId);
			return <span>{result?.name || "-"}</span>;
		}
	},
	{
		title: "关联月台",
		dataIndex: "scNames",
		width: 100,
		ellipsis: true,
	},
	{
		title: "起始站",
		dataIndex: "startSiteName",
		width: 140,
		ellipsis: true
	},
	{
		title: "终点站",
		dataIndex: "endSiteName",
		width: 140,
		ellipsis: true
	},
	{
		title: "接驳点总数",
		dataIndex: "countSite",
		width: 140,
		ellipsis: true
	},
	{
		title: "环线状态",
		dataIndex: "notice",
		width: 100,
		ellipsis: true,
		render: (_: any, record: any) => {
			return (
				<span style={{ color: '#3976F2', cursor: 'pointer' }}>
					{record.notice}
				</span>
			)
		}
	},
	{
		title: "创建日期",
		dataIndex: "createTime",
		width: 140,
		ellipsis: true
	},
];

export const USER_STATUS = [
	{ label: '在线', value: 1 },
	{ label: '离线', value: 2 }
]

export const getSearchColumns = ({orgList, sceneList, jointList}: any) => [
	{
		type: "input",
		placeholder: "环线名称",
		name: "loopName"
	},
	{
		type: "select",
		placeholder: "所属组织",
		name: "createOrgId",
		options: orgList?.data || [],
		fieldProps:{
			fieldNames: {
				label: 'name',  // 显示文本对应的字段
				value: 'id',    // 值对应的字段
			}
		}
	},
	{
		type: "select",
		placeholder: "关联月台",
		name: "scId",
		options: sceneList?.data?.list || [],
		fieldProps:{
			fieldNames: {
				label: 'scName',  // 显示文本对应的字段
				value: 'id',    // 值对应的字段
			}
		}
	},
	{
		type: "select",
		placeholder: "接驳点",
		name: "siteId",
		options: jointList?.data?.list || [],
		fieldProps:{
			fieldNames: {
				label: 'name',  // 显示文本对应的字段
				value: 'id',    // 值对应的字段
			}
		}
	},
]

export const SORT_LIST = [
	{ label: '1', value: 1 },
	{ label: '2', value: 2 },
	{ label: '3', value: 3 }
]


export const getCreateColumns = ({taskTypeList, carList}: any) => {
	return [
		{
			type: "input",
			placeholder: "任务名称",
			label: "任务名称",
			name: "jobName",
			rules: [{ required: true, message: '这是必填项' }]
		},
		{
			type: "select",
			placeholder: "任务类型",
			label: "任务类型",
			name: "jobType",
			rules: [
				{ required: true, message: '这是必填项' },
			],
			options: taskTypeList,
			fieldProps: {
				fieldNames: {
					label: 'label',  // 显示文本对应的字段
					value: 'value',    // 值对应的字段
				}
			}
		},
		{
			type: "select",
			placeholder: "请选择指定车辆",
			label: "指定车辆",
			name: "vehId",
			rules: [
				{ required: true, message: '这是必填项' },
			],
			options: carList?.list,
			fieldProps: {
				fieldNames: {
					label: 'plateNo',  // 显示文本对应的字段
					value: 'id',    // 值对应的字段
				}
			}
		},
		{
			type: "select",
			placeholder: "优先级",
			label: "优先级",
			name: "level",
			rules: [{ required: true, message: '这是必填项' }],
			options: SORT_LIST,
			fieldProps: {
				fieldNames: {
					label: 'label',  // 显示文本对应的字段
					value: 'value',    // 值对应的字段
				}
			}
		}
	]
}
